{
 "metadata": {
  "name": "Piecewise"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Piecewise"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "piecewise-defined functions"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import sys\n",
      "sys.path.append(\"D:\\Users\\guglie0p\\Dropbox\\Develop\\Python\\Goulib\")\n",
      "from Goulib.piecewise import *\n",
      "\n",
      "def plot(pwfs,ylim=None,labels=None,offset=None,max=None):\n",
      "    \"\"\"plots function\"\"\"\n",
      "    if isinstance(pwfs,Piecewise):\n",
      "        pwfs=[pwfs]\n",
      "    for i,pwf in enumerate(pwfs):\n",
      "        (x,y)=pwf.points(max=max)\n",
      "        if offset:\n",
      "            x=[x+i*offset for x in x]\n",
      "            y=[y+i*offset for y in y]\n",
      "        try:\n",
      "            label=labels[i]\n",
      "        except:\n",
      "            label=''\n",
      "        pylab.plot(x, y, label=label)\n",
      "        \n",
      "    if ylim: pylab.ylim(ylim)\n",
      "    if legend: pylab.legend()\n",
      "    pylab.show() "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The simplest are piecewise continuous functions. They are defined by $(x_i,y_i)$ tuples given in any order. \n",
      "\n",
      "$f(x) = \\begin{cases}y_0 & x < x_1 \\\\ y_i & x_i \\le x < x_{i+1} \\\\ y_n & x > x_n \\end{cases}$ (MathJax doesn't work properly in iPython...)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1=Piecewise([(4,4),(3,3),(1,1),(5,0)])\n",
      "plot(p1,max=6,ylim=(-1,5))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD9CAYAAAClQCyNAAAAB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tWr6uzs1IULF0Lza9knTpzQrFmzFIvFQnmF+n+XLl1Se3u7\nTp06pc8++0wtLS1Bj+SLwcFBtbW16d1331VbW5uef/557d69e8TjMxLwgoICJZPJ4Y+TyaQKCwsz\nsRQyZGBgQA0NDdqwYYPWrFkT9DgZM3PmTK1atUpXrlwJehRf/PTTT/ruu+80e/ZsrV+/Xj/88IM2\nbdoU9Fi+y8/PlyTl5OSovr5era2tAU/kj8LCQhUWFmrhwoWSpLVr1476xwIzEvCqqipdv35dHR0d\n6u/v19GjR7V69epMLIUMcF1XW7duVTQa1XvvvRf0OL67ffu2ent7JUmPHj3S2bNnFYvFAp7KHzt3\n7lQymdSNGzf09ddf64033tCRI0eCHstXDx8+1P379yVJDx480JkzZ0JzN1heXp6Kiop07do1SdK5\nc+dUVlY24vHj/mNWo4lEIjp48KBWrFihVCqlrVu3qrS0NBNLBWb9+vU6f/687ty5o6KiIn300Ufa\nvHlz0GP54tKlS/ryyy+Hb9OSpF27dmnlypUBT+aP7u5uNTU1aWhoSENDQ9q4caOWLFkS9FgZEcbt\nzFu3bqm+vl7Sn1sOjY2NWr58ecBT+efTTz9VY2Oj+vv7NWfOHB0+fHjEY0f9WygAgMkrvD+mBoCQ\nI+AAYBQBBwCjCDgAGEXAAcAoAg4ARv0XHBv7hIoIiaIAAAAASUVORK5CYII=\n"
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "By default $x_0 = 0$ , but it can be specified at construction\n",
      "Piecewise functions can also be defined by adding (x0,y,x1) segments"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p2=Piecewise(default=1)\n",
      "p2+=(2.5,1,6.5)\n",
      "p2+=(1.5,1,3.5)\n",
      "plot(p2,max=7,ylim=(-1,5))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD9CAYAAAClQCyNAAAABHNCSVQICA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np08\neVJfffWVLly4EPRIngwMDKi1tVUffvihWltb9corr2jbtm1Bj5W0eDyuY8eO6b333hv2uIwEfPLk\nyYrFYkNfx2IxFRYWZmIpPMPDhw/V0NCgVatWadmyZUGPk7KcnBwtWbJEly9fDnoUz37++Wf98MMP\nmjJlihobG/Xjjz9qzZo1QY+VlEmTJkmS8vPzVV9fr5aWloAn8qawsFCFhYWaPXu2JGn58uUmf9ne\nyZMnNWvWLOXn5w97XEYCXlVVpWvXrqm9vV3xeFyHDx/W0qVLM7EUnsJ1XW3YsEGhUEgfffRR0OMk\n7fbt2+ru7pYk9ff368yZMwqHwwFP5d2WLVsUi8V0/fp1HTp0SO+8844OHDgQ9Fie9fX1qaenR5LU\n29ur06dPm3kaq6CgQEVFRbp69aqkR/vIZWVlAU+VvIMHD6qxsXHE41L+ZVbDXjQrS3v37tWiRYuU\nSCS0YcMGlZaWZmKpjGlsbNS5c+d0584dFRUV6fPPP9e6deuCHsuTixcv6ttvvx16DEyStm7dqsWL\nFwc8mTednZ1au3atBgcHNTg4qNWrV2vevHlBj5Uya1uKt27dUn19vaRHWxJNTU1auHBhwFN59+WX\nX6qpqUnxeFxTp07V/v37gx4pKb29vTp79qyn1x6G/V0oAIDnl82XyAEABBwArCLgAGAUAQcAowg4\nABhFwAHAqP8BcB4Br/DW4DQAAAAASUVORK5CYII=\n"
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plot([p1,p2,p1+p2,p1*p2,p1/p2],labels=['p1','p2','p1+p2','p1*p2','p1/p2'],max=7,ylim=(-1,10), offset=0.02)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD9CAYAAACcJ53WAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGv1JREFUeJzt3X1QFPcdBvBnFTLxhZc7VDC8VMaXyIsCVcOoVA+rmFFR\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S0NL3jdCsgIABz587FpUuX9I7SQUlJCY4e\nPYrIyEhkZGTg9OnTyMzM1DtWp4YPHw4AGDp0KF566SVcvHhR50QdhYWFISwsDJMmTQIApKeno7S0\nVOdUzp04cQITJkzA0KFD9Y7SwaVLlzBlyhQEBQXBx8cHL7/8MkpKSpxeX/XinjhxIr755htUVFTA\nZrPhk08+wfz589XeTJ8gyzJWr16N6OhoZGVl6R3HqXv37qG2thYA0NjYiJMnTyIhIUHnVB3t2LED\nlZWVsFgsOHLkCGbMmIFDhw7pHauDhoYGPHjwAADw8OFDfP755x756qeQkBCEh4ejvLwcQOvx45iY\nGJ1TOXf48GFkZGToHaNTY8eOxfnz59HY2AhZlnHq1KmuDzdq8Qxpfn6+PGbMGHnkyJHyjh07tNhE\njy1evFgePny4/Mwzz8hhYWHyH//4R70jdVBUVCRLkiTHxcXJ8fHxcnx8vHzixAm9Y3Xw5ZdfygkJ\nCXJcXJw8btw4effu3XpH6pbZbPbYV5X897//lePi4uS4uDg5JibGY3+HZFmWL1++LE+cOFEeP368\n/NJLL3nsq0rq6+vloKAgua6uTu8oTu3atUuOjo6WY2Nj5czMTNlmszm9rmbnKiEiIm149lPrRETU\nAYubiEgwLG4iIsGwuImIBMPiJiISDIubiEgw/wd6qlMvtVbh2AAAAABJRU5ErkJggg==\n"
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}